package com.zf.yichat.service;

import com.zf.yichat.dto.SaleChartItem;
import com.zf.yichat.model.*;
import com.zf.yichat.utils.response.FsPage;
import com.zf.yichat.utils.response.FsResponse;
import com.zf.yichat.vo.BalanceType;
import com.zf.yichat.vo.PayType;
import org.apache.commons.lang3.tuple.Pair;

import java.math.BigDecimal;
import java.util.List;

/**
 * 一句话描述功能
 *
 * @author fengsong
 * @date create in 16:43 2019/6/10 2019
 */
public interface BalanceService {

    /**
     * 线下转账功能
     * @param status
     * @param reason
     * @param withdraw
     */
    void doWithdraw(Integer status, String reason, UserWithdraw withdraw);

    FsResponse checkWithdrawForHj(Integer userId, Integer status, String reason);

    /**
     * 余额账号创建
     */
    void create(Long userId);

    Pair<Long, BigDecimal> sumUserBalance();

    /**
     * 更新余额
     */
    void update(Long userId, BalanceType type, BigDecimal money, Long referId, String memo);

    /**
     * 更新支付密码
     */
    void updatePassword(Long userId, String password);

    /**
     * 校验支付密码
     */
    void checkPassword(Long userId, String password);

    UserBalance selectByUserId(Long userId);

    // 查询用户当前的余额（余额详情的最后一次记录）
    String queryDetailsLastTime(Long userId);

    void record(Long userId, Integer type, BigDecimal money, BigDecimal balance, BigDecimal freezeMoney, BigDecimal incomeMoney, Long referId, String desc);

    /**
     * 用户余额明细
     * type 0 支出  1 收入
     */
    FsResponse selectList(Integer type, Long userId, String ctime);

    List<UserBalanceDetail> selectSaleDisList(Integer limit);

    FsResponse checkWithdraw(Integer id, Integer status, String reason);

    /**
     * 生成交易记录
     *
     * @param userId    用户ID
     * @param tradeId   订单号
     * @param money     金额
     * @param payType   支付类型
     * @param tradeType 交易类型
     */
    Long createTradeRecord(Long userId, String tradeId, BigDecimal money, PayType payType, Integer tradeType);

    UserTrade selectTradeByTradeNo(String tradeNo);

    void completeTrade(Long id);

    BigDecimal selectTotalByType(Long userId, BalanceType type);

    List<SaleChartItem> selectChartList();

    Long selectOrderNum(BigDecimal money);

    UserBalanceDetail selectDetailByReferId(Long missionId, BalanceType mission);

}
